﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace D20.Entities.Items
{
    /// <summary>
    /// A container of objects.
    /// </summary>
    [Serializable]
    public class Container: Item
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Container"/> class.
        /// </summary>
        public Container():this(new Inventory(), int.MaxValue)
        {

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Container"/> class.
        /// </summary>
        /// <param name="contents">The contents.</param>
        public Container(IEnumerable<Item> contents)//:this(new Inventory(contents), contents.Count())
        {
            if (contents == null)
            {
                Contents = new Inventory();
                Contents.Capacity = int.MaxValue;
            }
            else
            {
                Contents = new Inventory(contents);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Container"/> class.
        /// </summary>
        /// <param name="contents">The contents.</param>
        /// <param name="capacity">The capacity.</param>
        public Container(IEnumerable<Item> contents, int capacity):this(new Inventory(contents), capacity)
        {

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Container"/> class.
        /// </summary>
        /// <param name="inventory">The inventory.</param>
        public Container(Inventory inventory):this(inventory, inventory.Contents.Count)
        {

        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Container"/> class.
        /// </summary>
        /// <param name="inventory">The inventory.</param>
        /// <param name="capacity">The capacity.</param>
        public Container(Inventory inventory, int capacity)
        {
            Contents = inventory;
            Contents.Capacity = capacity;
        }
        /// <summary>
        /// Gets the contents of the container.
        /// </summary>
        /// <value>The contents.</value>
        public Inventory Contents { get; private set; }

    }
}
